package easycloud.ecs.web.util;

import javax.inject.Inject;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Service;

import easycloud.ecs.common.domain.Folder;
import easycloud.ecs.web.service.FolderService;

@Service
public class FolderConverter implements Converter<String, Folder> {

	@Inject
	private FolderService folderService;

	@Override
	public Folder convert(String arg0) {
		Integer folderId = Integer.parseInt(arg0);
		if (folderId >= 0) {
			return folderService.getFolder(folderId);
		} else {
			return null;
		}
	}
}